home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / UIComponentsExample.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  39.0 KB  |  1,308 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  22 Aug 2000
  22. //  Author:         bwk
  23. //
  24. //  Description:
  25. //        This script demonstrates the use of UI Components.
  26. //
  27.  
  28. proc createStatusLine(string $parent)
  29. //
  30. //    Description:
  31. //        This procedure is called whenever you want to create the content for
  32. //        the corresponding UI Component.
  33. //
  34. //    Arguments:
  35. //        parent - The parent control layout. Must be a formLayout.
  36. //
  37. {
  38.     //    Ensure the argument layout is the correct type.
  39.     //
  40.     string $requiredType = "formLayout";
  41.     if ($requiredType != `objectTypeUI $parent`) {
  42.         error -showLineNumber true ("Argument must be a " + $requiredType);
  43.         return;
  44.     }
  45.     
  46.     setParent $parent;
  47.     string $component = `button -label "Status Line"`;
  48.  
  49.     formLayout -edit
  50.         -attachForm     $component  "top"    0
  51.         -attachForm     $component  "left"   0
  52.         -attachForm     $component  "bottom" 0
  53.         -attachForm     $component  "right"  0
  54.         $parent;
  55. }
  56.  
  57. proc createShelf(string $parent)
  58. //
  59. //    Description:
  60. //        This procedure is called whenever you want to create the content for
  61. //        the corresponding UI Component.
  62. //
  63. //    Arguments:
  64. //        parent - The parent control layout. Must be a formLayout.
  65. //
  66. {
  67.     //    Ensure the argument layout is the correct type.
  68.     //
  69.     string $requiredType = "formLayout";
  70.     if ($requiredType != `objectTypeUI $parent`) {
  71.         error -showLineNumber true ("Argument must be a " + $requiredType);
  72.         return;
  73.     }
  74.     
  75.     setParent $parent;
  76.     string $component = `button -label "Shelf"`;
  77.     formLayout -edit
  78.         -attachForm     $component  "top"    0
  79.         -attachForm     $component  "left"   0
  80.         -attachForm     $component  "bottom" 0
  81.         -attachForm     $component  "right"  0
  82.         $parent;
  83. }
  84.  
  85. proc createLayerBar(string $parent)
  86. //
  87. //    Description:
  88. //        This procedure is called whenever you want to create the content for
  89. //        the corresponding UI Component.
  90. //
  91. //    Arguments:
  92. //        parent - The parent control layout. Must be a formLayout.
  93. //
  94. {
  95.     //    Ensure the argument layout is the correct type.
  96.     //
  97.     string $requiredType = "formLayout";
  98.     if ($requiredType != `objectTypeUI $parent`) {
  99.         error -showLineNumber true ("Argument must be a " + $requiredType);
  100.         return;
  101.     }
  102.     
  103.     setParent $parent;
  104.     string $component = `button -label "Layer Bar"`;
  105.     formLayout -edit
  106.         -attachForm     $component  "top"    0
  107.         -attachForm     $component  "left"   0
  108.         -attachForm     $component  "bottom" 0
  109.         -attachForm     $component  "right"  0
  110.         $parent;
  111. }
  112.  
  113. proc createWorkArea(string $parent)
  114. //
  115. //    Description:
  116. //        This procedure is called whenever you want to create the content for
  117. //        the corresponding UI Component.
  118. //
  119. //    Arguments:
  120. //        parent - The parent control layout. Must be a formLayout.
  121. //
  122. {
  123.     //    Ensure the argument layout is the correct type.
  124.     //
  125.     string $requiredType = "formLayout";
  126.     if ($requiredType != `objectTypeUI $parent`) {
  127.         error -showLineNumber true ("Argument must be a " + $requiredType);
  128.         return;
  129.     }
  130.     
  131.     setParent $parent;
  132.     string $workArea = `text -label "Work Area" -align "center"`;
  133.     formLayout -edit
  134.         -attachForm     $workArea  "top"    0
  135.         -attachForm     $workArea  "left"   0
  136.         -attachForm     $workArea  "bottom" 0
  137.         -attachForm     $workArea  "right"  0
  138.         $parent;
  139. }
  140.  
  141. proc createTimeLine(string $parent)
  142. //
  143. //    Description:
  144. //        This procedure is called whenever you want to create the content for
  145. //        the corresponding UI Component.
  146. //
  147. //    Arguments:
  148. //        parent - The parent control layout. Must be a formLayout.
  149. //
  150. {
  151.     //    Ensure the argument layout is the correct type.
  152.     //
  153.     string $requiredType = "formLayout";
  154.     if ($requiredType != `objectTypeUI $parent`) {
  155.         error -showLineNumber true ("Argument must be a " + $requiredType);
  156.         return;
  157.     }
  158.     
  159.     setParent $parent;
  160.     string $component = `button -label "Time Line"`;
  161.     formLayout -edit
  162.         -attachForm     $component  "top"    0
  163.         -attachForm     $component  "left"   0
  164.         -attachForm     $component  "bottom" 0
  165.         -attachForm     $component  "right"  0
  166.         $parent;
  167. }
  168.  
  169. proc createPlaybackRange(string $parent)
  170. //
  171. //    Description:
  172. //        This procedure is called whenever you want to create the content for
  173. //        the corresponding UI Component.
  174. //
  175. //    Arguments:
  176. //        parent - The parent control layout. Must be a formLayout.
  177. //
  178. {
  179.     //    Ensure the argument layout is the correct type.
  180.     //
  181.     string $requiredType = "formLayout";
  182.     if ($requiredType != `objectTypeUI $parent`) {
  183.         error -showLineNumber true ("Argument must be a " + $requiredType);
  184.         return;
  185.     }
  186.     
  187.     setParent $parent;
  188.     string $component = `button -label "Playback Range"`;
  189.     formLayout -edit
  190.         -attachForm     $component  "top"    0
  191.         -attachForm     $component  "left"   0
  192.         -attachForm     $component  "bottom" 0
  193.         -attachForm     $component  "right"  0
  194.         $parent;
  195. }
  196.  
  197. proc createCommandLine(string $parent)
  198. //
  199. //    Description:
  200. //        This procedure is called whenever you want to create the content for
  201. //        the corresponding UI Component.
  202. //
  203. //    Arguments:
  204. //        parent - The parent control layout. Must be a formLayout.
  205. //
  206. {
  207.     //    Ensure the argument layout is the correct type.
  208.     //
  209.     string $requiredType = "formLayout";
  210.     if ($requiredType != `objectTypeUI $parent`) {
  211.         error -showLineNumber true ("Argument must be a " + $requiredType);
  212.         return;
  213.     }
  214.     
  215.     setParent $parent;
  216.     string $component = `textField -text "Command Line"`;
  217.     formLayout -edit
  218.         -attachForm     $component  "top"    0
  219.         -attachForm     $component  "left"   0
  220.         -attachForm     $component  "bottom" 0
  221.         -attachForm     $component  "right"  0
  222.         $parent;
  223. }
  224.  
  225. proc createHelpLine(string $parent)
  226. //
  227. //    Description:
  228. //        This procedure is called whenever you want to create the content for
  229. //        the corresponding UI Component.
  230. //
  231. //    Arguments:
  232. //        parent - The parent control layout. Must be a formLayout.
  233. //
  234. {
  235.     //    Ensure the argument layout is the correct type.
  236.     //
  237.     string $requiredType = "formLayout";
  238.     if ($requiredType != `objectTypeUI $parent`) {
  239.         error -showLineNumber true ("Argument must be a " + $requiredType);
  240.         return;
  241.     }
  242.     
  243.     setParent $parent;
  244.     string $component = `textField -text "Help Line" -editable false`;
  245.     formLayout -edit
  246.         -attachForm     $component  "top"    0
  247.         -attachForm     $component  "left"   0
  248.         -attachForm     $component  "bottom" 0
  249.         -attachForm     $component  "right"  0
  250.         $parent;
  251. }
  252.  
  253. proc createToolbox(string $parent)
  254. //
  255. //    Description:
  256. //        This procedure is called whenever you want to create the content for
  257. //        the corresponding UI Component.
  258. //
  259. //    Arguments:
  260. //        parent - The parent control layout. Must be a formLayout.
  261. //
  262. {
  263.     //    Ensure the argument layout is the correct type.
  264.     //
  265.     string $requiredType = "formLayout";
  266.     if ($requiredType != `objectTypeUI $parent`) {
  267.         error -showLineNumber true ("Argument must be a " + $requiredType);
  268.         return;
  269.     }
  270.     
  271.     setParent $parent;
  272.     string $component = `button -label "Tools"`;
  273.     formLayout -edit
  274.         -attachForm     $component  "top"    0
  275.         -attachForm     $component  "left"   0
  276.         -attachForm     $component  "bottom" 0
  277.         -attachForm     $component  "right"  0
  278.         $parent;
  279. }
  280.  
  281. proc createChannelBox(string $parent)
  282. //
  283. //    Description:
  284. //        This procedure is called whenever you want to create the content for
  285. //        the corresponding UI Component.
  286. //
  287. //    Arguments:
  288. //        parent - The parent control layout. Must be a formLayout.
  289. //
  290. {
  291.     //    Ensure the argument layout is the correct type.
  292.     //
  293.     string $requiredType = "formLayout";
  294.     if ($requiredType != `objectTypeUI $parent`) {
  295.         error -showLineNumber true ("Argument must be a " + $requiredType);
  296.         return;
  297.     }
  298.     
  299.     setParent $parent;
  300.  
  301.     string $widthControl = `separator -width 160`;
  302.     string $component = `scrollLayout`;
  303.  
  304.     columnLayout;
  305.  
  306.     textFieldGrp -label "Channel 1" -columnWidth2 70 60;
  307.     textFieldGrp -label "Channel 2" -columnWidth2 70 60;
  308.     textFieldGrp -label "Channel 3" -columnWidth2 70 60;
  309.     textFieldGrp -label "Channel 4" -columnWidth2 70 60;
  310.     textFieldGrp -label "Channel 5" -columnWidth2 70 60;
  311.     textFieldGrp -label "Channel 6" -columnWidth2 70 60;
  312.  
  313.     formLayout -edit
  314.         -attachForm     $component  "top"    0
  315.         -attachForm     $component  "left"   0
  316.         -attachForm     $component  "bottom" 0
  317.         -attachForm     $component  "right"  0
  318.         $parent;
  319. }
  320.  
  321. proc createAttributeEditor(string $parent)
  322. //
  323. //    Description:
  324. //        This procedure is called whenever you want to create the content for
  325. //        the corresponding UI Component.
  326. //
  327. //    Arguments:
  328. //        parent - The parent control layout. Must be a formLayout.
  329. //
  330. {
  331.     //    Ensure the argument layout is the correct type.
  332.     //
  333.     string $requiredType = "formLayout";
  334.     if ($requiredType != `objectTypeUI $parent`) {
  335.         error -showLineNumber true ("Argument must be a " + $requiredType);
  336.         return;
  337.     }
  338.     
  339.     setParent $parent;
  340.  
  341.     string $widthControl = `separator -width 250`;
  342.     string $component = `scrollLayout`;
  343.  
  344.     columnLayout;
  345.  
  346.     floatSliderGrp -label "Attribute 1" 
  347.         -field true -columnWidth3 70 50 100
  348.         -columnAttach 3 "both" 0;
  349.     floatSliderGrp -label "Attribute 2" 
  350.         -field true -columnWidth3 70 50 100
  351.         -columnAttach 3 "both" 0;
  352.     floatSliderGrp -label "Attribute 3" 
  353.         -field true -columnWidth3 70 50 100
  354.         -columnAttach 3 "both" 0;
  355.     floatSliderGrp -label "Attribute 4" 
  356.         -field true -columnWidth3 70 50 100
  357.         -columnAttach 3 "both" 0;
  358.     floatSliderGrp -label "Attribute 5" 
  359.         -field true -columnWidth3 70 50 100
  360.         -columnAttach 3 "both" 0;
  361.     floatSliderGrp -label "Attribute 6" 
  362.         -field true -columnWidth3 70 50 100
  363.         -columnAttach 3 "both" 0;
  364.  
  365.     formLayout -edit
  366.         -attachForm     $component  "top"    0
  367.         -attachForm     $component  "left"   0
  368.         -attachForm     $component  "bottom" 0
  369.         -attachForm     $component  "right"  0
  370.         $parent;
  371. }
  372.  
  373. proc createOptionBox(string $parent)
  374. //
  375. //    Description:
  376. //        This procedure is called whenever you want to create the content for
  377. //        the corresponding UI Component.
  378. //
  379. //    Arguments:
  380. //        parent - The parent control layout. Must be a formLayout.
  381. //
  382. {
  383.     //    Ensure the argument layout is the correct type.
  384.     //
  385.     string $requiredType = "formLayout";
  386.     if ($requiredType != `objectTypeUI $parent`) {
  387.         error -showLineNumber true ("Argument must be a " + $requiredType);
  388.         return;
  389.     }
  390.     
  391.     setParent $parent;
  392.  
  393.     string $widthControl = `separator -width 120`;
  394.     string $component = `scrollLayout`;
  395.  
  396.     columnLayout;
  397.  
  398.     checkBoxGrp -label "Option 1" -columnWidth2 70 20;
  399.     checkBoxGrp -label "Option 2" -columnWidth2 70 20;
  400.     checkBoxGrp -label "Option 3" -columnWidth2 70 20;
  401.     checkBoxGrp -label "Option 4" -columnWidth2 70 20;
  402.     checkBoxGrp -label "Option 5" -columnWidth2 70 20;
  403.     checkBoxGrp -label "Option 6" -columnWidth2 70 20;
  404.  
  405.     formLayout -edit
  406.         -attachForm     $component  "top"    0
  407.         -attachForm     $component  "left"   0
  408.         -attachForm     $component  "bottom" 0
  409.         -attachForm     $component  "right"  0
  410.         $parent;
  411. }
  412.  
  413. global proc UIComponentExampleWindowUpdateDisplayMenu()
  414. //
  415. //    Description:
  416. //        Update the state of the menu that also controls the visibility of the
  417. //        UI components in the window.
  418. //
  419. //        This procedure needs only be called when the menu is about to be
  420. //        shown (ie. via the menu -postMenuCommand command). It would be best if
  421. //        this menu is not tear offable because while torn off a menu does not
  422. //        get messages to update itself.
  423. //
  424. {
  425.     int $visible;
  426.  
  427.     //    Get the visibility of all the components and update the corresponding 
  428.     //    menu item.
  429.     //
  430.     $visible = isUIComponentVisible("Example Status Line");
  431.     menuItem -edit -checkBox $visible UIComponentExampleWindowStatusLineMenuItem;
  432.  
  433.     $visible = isUIComponentVisible("Example Shelf");
  434.     menuItem -edit -checkBox $visible UIComponentExampleWindowShelfMenuItem;
  435.  
  436.     $visible = isUIComponentVisible("Example Layer Bar");
  437.     menuItem -edit -checkBox $visible UIComponentExampleWindowLayerBarMenuItem;
  438.  
  439.     $visible = isUIComponentVisible("Example Time Line");
  440.     menuItem -edit -checkBox $visible UIComponentExampleWindowTimeLineMenuItem;
  441.  
  442.     $visible = isUIComponentVisible("Example Playback Range");
  443.     menuItem -edit -checkBox $visible UIComponentExampleWindowPlaybackRangeMenuItem;
  444.  
  445.     $visible = isUIComponentVisible("Example Command Line");
  446.     menuItem -edit -checkBox $visible UIComponentExampleWindowCommandLineMenuItem;
  447.  
  448.     $visible = isUIComponentVisible("Example Help Line");
  449.     menuItem -edit -checkBox $visible UIComponentExampleWindowHelpLineMenuItem;
  450.  
  451.     $visible = isUIComponentVisible("Example Toolbox");
  452.     menuItem -edit -checkBox $visible UIComponentExampleWindowToolboxMenuItem;
  453.  
  454.     $visible = isUIComponentVisible("Example Channel Box");
  455.     menuItem -edit -checkBox $visible UIComponentExampleWindowChannelBoxMenuItem;
  456.  
  457.     $visible = isUIComponentVisible("Example Attribute Editor");
  458.     menuItem -edit -checkBox $visible UIComponentExampleWindowAttributeEditorMenuItem;
  459.  
  460.     $visible = isUIComponentVisible("Example Option Box");
  461.     menuItem -edit -checkBox $visible UIComponentExampleWindowOptionBoxMenuItem;
  462. }
  463.  
  464. global proc int UIComponentExampleWindowStatusLineStateChange(
  465.     int    $newState,
  466.     string $layout)
  467. //
  468. //    Description:
  469. //        This procedure is called whenever the visibility of the
  470. //        corresponding UI component changes.
  471. //
  472. //        If necessary, you can use this procedure to create the 
  473. //        UI component content the first time the component is made
  474. //        visible.
  475. //
  476. //    Arguments:
  477. //        newState - The new visibility state of the component. Will 
  478. //                   be true if the component is about to be shown, 
  479. //                   false if the component is about to be hidden.
  480. //
  481. //        layout -   The parent layout for the UI component content.
  482. //
  483. //    Returns:
  484. //        True if you want to allow the visibility state change. Return
  485. //        false if you want to prevent the change.
  486. //
  487. {
  488.     if ($newState) {
  489.         //
  490.         //    If the component has not been created yet then do it now.
  491.         //
  492.         if (0 == `layout -query -numberOfChildren $layout`) {
  493.             createStatusLine($layout);
  494.         }
  495.  
  496.     } else {
  497.     }
  498.  
  499.     return true;
  500. }
  501.  
  502. global proc int UIComponentExampleWindowShelfStateChange(
  503.     int    $newState,
  504.     string $layout)
  505. //
  506. //    Description:
  507. //        This procedure is called whenever the visibility of the
  508. //        corresponding UI component changes.
  509. //
  510. //        If necessary, you can use this procedure to create the 
  511. //        UI component content the first time the component is made
  512. //        visible.
  513. //
  514. //    Arguments:
  515. //        newState - The new visibility state of the component. Will 
  516. //                   be true if the component is about to be shown, 
  517. //                   false if the component is about to be hidden.
  518. //
  519. //        layout -   The parent layout for the UI component content.
  520. //
  521. //    Returns:
  522. //        True if you want to allow the visibility state change. Return
  523. //        false if you want to prevent the change.
  524. //
  525. {
  526.     if ($newState) {
  527.         //
  528.         //    If the component has not been created yet then do it now.
  529.         //
  530.         if (0 == `layout -query -numberOfChildren $layout`) {
  531.             createShelf($layout);
  532.         }
  533.  
  534.     } else {
  535.     }
  536.  
  537.     return true;
  538. }
  539.  
  540. global proc int UIComponentExampleWindowLayerBarStateChange(
  541.     int    $newState,
  542.     string $layout)
  543. //
  544. //    Description:
  545. //        This procedure is called whenever the visibility of the
  546. //        corresponding UI component changes.
  547. //
  548. //        If necessary, you can use this procedure to create the 
  549. //        UI component content the first time the component is made
  550. //        visible.
  551. //
  552. //    Arguments:
  553. //        newState - The new visibility state of the component. Will 
  554. //                   be true if the component is about to be shown, 
  555. //                   false if the component is about to be hidden.
  556. //
  557. //        layout -   The parent layout for the UI component content.
  558. //
  559. //    Returns:
  560. //        True if you want to allow the visibility state change. Return
  561. //        false if you want to prevent the change.
  562. //
  563. {
  564.     if ($newState) {
  565.         //
  566.         //    If the component has not been created yet then do it now.
  567.         //
  568.         if (0 == `layout -query -numberOfChildren $layout`) {
  569.             createLayerBar($layout);
  570.         }
  571.  
  572.     } else {
  573.     }
  574.  
  575.     return true;
  576. }
  577.  
  578. global proc int UIComponentExampleWindowTimeLineStateChange(
  579.     int    $newState,
  580.     string $layout)
  581. //
  582. //    Description:
  583. //        This procedure is called whenever the visibility of the
  584. //        corresponding UI component changes.
  585. //
  586. //        If necessary, you can use this procedure to create the 
  587. //        UI component content the first time the component is made
  588. //        visible.
  589. //
  590. //    Arguments:
  591. //        newState - The new visibility state of the component. Will 
  592. //                   be true if the component is about to be shown, 
  593. //                   false if the component is about to be hidden.
  594. //
  595. //        layout -   The parent layout for the UI component content.
  596. //
  597. //    Returns:
  598. //        True if you want to allow the visibility state change. Return
  599. //        false if you want to prevent the change.
  600. //
  601. {
  602.     if ($newState) {
  603.         //
  604.         //    If the component has not been created yet then do it now.
  605.         //
  606.         if (0 == `layout -query -numberOfChildren $layout`) {
  607.             createTimeLine($layout);
  608.         }
  609.  
  610.     } else {
  611.     }
  612.  
  613.     return true;
  614. }
  615.  
  616. global proc int UIComponentExampleWindowPlaybackRangeStateChange(
  617.     int    $newState,
  618.     string $layout)
  619. //
  620. //    Description:
  621. //        This procedure is called whenever the visibility of the
  622. //        corresponding UI component changes.
  623. //
  624. //        If necessary, you can use this procedure to create the 
  625. //        UI component content the first time the component is made
  626. //        visible.
  627. //
  628. //    Arguments:
  629. //        newState - The new visibility state of the component. Will 
  630. //                   be true if the component is about to be shown, 
  631. //                   false if the component is about to be hidden.
  632. //
  633. //        layout -   The parent layout for the UI component content.
  634. //
  635. //    Returns:
  636. //        True if you want to allow the visibility state change. Return
  637. //        false if you want to prevent the change.
  638. //
  639. {
  640.     if ($newState) {
  641.         //
  642.         //    If the component has not been created yet then do it now.
  643.         //
  644.         if (0 == `layout -query -numberOfChildren $layout`) {
  645.             createPlaybackRange($layout);
  646.         }
  647.  
  648.     } else {
  649.     }
  650.  
  651.     return true;
  652. }
  653.  
  654. global proc int UIComponentExampleWindowCommandLineStateChange(
  655.     int    $newState,
  656.     string $layout)
  657. //
  658. //    Description:
  659. //        This procedure is called whenever the visibility of the
  660. //        corresponding UI component changes.
  661. //
  662. //        If necessary, you can use this procedure to create the 
  663. //        UI component content the first time the component is made
  664. //        visible.
  665. //
  666. //    Arguments:
  667. //        newState - The new visibility state of the component. Will 
  668. //                   be true if the component is about to be shown, 
  669. //                   false if the component is about to be hidden.
  670. //
  671. //        layout -   The parent layout for the UI component content.
  672. //
  673. //    Returns:
  674. //        True if you want to allow the visibility state change. Return
  675. //        false if you want to prevent the change.
  676. //
  677. {
  678.     if ($newState) {
  679.         //
  680.         //    If the component has not been created yet then do it now.
  681.         //
  682.         if (0 == `layout -query -numberOfChildren $layout`) {
  683.             createCommandLine($layout);
  684.         }
  685.  
  686.     } else {
  687.     }
  688.  
  689.     return true;
  690. }
  691.  
  692. global proc int UIComponentExampleWindowHelpLineStateChange(
  693.     int    $newState,
  694.     string $layout)
  695. //
  696. //    Description:
  697. //        This procedure is called whenever the visibility of the
  698. //        corresponding UI component changes.
  699. //
  700. //        If necessary, you can use this procedure to create the 
  701. //        UI component content the first time the component is made
  702. //        visible.
  703. //
  704. //    Arguments:
  705. //        newState - The new visibility state of the component. Will 
  706. //                   be true if the component is about to be shown, 
  707. //                   false if the component is about to be hidden.
  708. //
  709. //        layout -   The parent layout for the UI component content.
  710. //
  711. //    Returns:
  712. //        True if you want to allow the visibility state change. Return
  713. //        false if you want to prevent the change.
  714. //
  715. {
  716.     if ($newState) {
  717.         //
  718.         //    If the component has not been created yet then do it now.
  719.         //
  720.         if (0 == `layout -query -numberOfChildren $layout`) {
  721.             createHelpLine($layout);
  722.         }
  723.  
  724.     } else {
  725.     }
  726.  
  727.     return true;
  728. }
  729.  
  730. global proc int UIComponentExampleWindowToolboxStateChange(
  731.     int    $newState,
  732.     string $layout)
  733. //
  734. //    Description:
  735. //        This procedure is called whenever the visibility of the
  736. //        corresponding UI component changes.
  737. //
  738. //        If necessary, you can use this procedure to create the 
  739. //        UI component content the first time the component is made
  740. //        visible.
  741. //
  742. //    Arguments:
  743. //        newState - The new visibility state of the component. Will 
  744. //                   be true if the component is about to be shown, 
  745. //                   false if the component is about to be hidden.
  746. //
  747. //        layout -   The parent layout for the UI component content.
  748. //
  749. //    Returns:
  750. //        True if you want to allow the visibility state change. Return
  751. //        false if you want to prevent the change.
  752. //
  753. {
  754.     if ($newState) {
  755.         //
  756.         //    If the component has not been created yet then do it now.
  757.         //
  758.         if (0 == `layout -query -numberOfChildren $layout`) {
  759.             createToolbox($layout);
  760.         }
  761.  
  762.     } else {
  763.     }
  764.  
  765.     return true;
  766. }
  767.  
  768. global proc int UIComponentExampleWindowChannelBoxStateChange(
  769.     int    $newState,
  770.     string $layout)
  771. //
  772. //    Description:
  773. //        This procedure is called whenever the visibility of the
  774. //        corresponding UI component changes.
  775. //
  776. //        If necessary, you can use this procedure to create the 
  777. //        UI component content the first time the component is made
  778. //        visible.
  779. //
  780. //    Arguments:
  781. //        newState - The new visibility state of the component. Will 
  782. //                   be true if the component is about to be shown, 
  783. //                   false if the component is about to be hidden.
  784. //
  785. //        layout -   The parent layout for the UI component content.
  786. //
  787. //    Returns:
  788. //        True if you want to allow the visibility state change. Return
  789. //        false if you want to prevent the change.
  790. //
  791. {
  792.     if ($newState) {
  793.         //
  794.         //    If the component has not been created yet then do it now.
  795.         //
  796.         if (0 == `layout -query -numberOfChildren $layout`) {
  797.             createChannelBox($layout);
  798.         }
  799.  
  800.     } else {
  801.     }
  802.  
  803.     return true;
  804. }
  805.  
  806. global proc int UIComponentExampleWindowAttributeEditorStateChange(
  807.     int    $newState,
  808.     string $layout)
  809. //
  810. //    Description:
  811. //        This procedure is called whenever the visibility of the
  812. //        corresponding UI component changes.
  813. //
  814. //        If necessary, you can use this procedure to create the 
  815. //        UI component content the first time the component is made
  816. //        visible.
  817. //
  818. //    Arguments:
  819. //        newState - The new visibility state of the component. Will 
  820. //                   be true if the component is about to be shown, 
  821. //                   false if the component is about to be hidden.
  822. //
  823. //        layout -   The parent layout for the UI component content.
  824. //
  825. //    Returns:
  826. //        True if you want to allow the visibility state change. Return
  827. //        false if you want to prevent the change.
  828. //
  829. {
  830.     if ($newState) {
  831.         //
  832.         //    If the component has not been created yet then do it now.
  833.         //
  834.         if (0 == `layout -query -numberOfChildren $layout`) {
  835.             createAttributeEditor($layout);
  836.         }
  837.  
  838.     } else {
  839.     }
  840.  
  841.     return true;
  842. }
  843.  
  844. global proc int UIComponentExampleWindowOptionBoxStateChange(
  845.     int    $newState,
  846.     string $layout)
  847. //
  848. //    Description:
  849. //        This procedure is called whenever the visibility of the
  850. //        corresponding UI component changes.
  851. //
  852. //        If necessary, you can use this procedure to create the 
  853. //        UI component content the first time the component is made
  854. //        visible.
  855. //
  856. //    Arguments:
  857. //        newState - The new visibility state of the component. Will 
  858. //                   be true if the component is about to be shown, 
  859. //                   false if the component is about to be hidden.
  860. //
  861. //        layout -   The parent layout for the UI component content.
  862. //
  863. //    Returns:
  864. //        True if you want to allow the visibility state change. Return
  865. //        false if you want to prevent the change.
  866. //
  867. {
  868.     if ($newState) {
  869.         //
  870.         //    If the component has not been created yet then do it now.
  871.         //
  872.         if (0 == `layout -query -numberOfChildren $layout`) {
  873.             createOptionBox($layout);
  874.         }
  875.  
  876.     } else {
  877.     }
  878.  
  879.     return true;
  880. }
  881.  
  882. //
  883. //    Description:
  884. //        Create a window demonstrating how to set up UI Components.
  885. //
  886. //        Simply execute the command "source UIComponentsExample.mel".
  887. //
  888. {
  889.     //    Delete the window if it already exists. You don't typically do
  890.     //    this for regular windows but it is quite handy during prototyping
  891.     //    UI and you continually source the same script over and over again.
  892.     //    This will allow you to use the same window and prevent a 
  893.     //    proliferation of default windows called "window1", "window2",
  894.     //    "window3", etc.
  895.     //
  896.     if (`window -exists UIComponentsExampleWindow`) {
  897.         deleteUI -window UIComponentsExampleWindow;
  898.     }
  899.  
  900.     //    Create the window with a menu bar.
  901.     //
  902.     $window = `window -menuBar true
  903.         -title "UI Components Example Window"
  904.         UIComponentsExampleWindow`;
  905.  
  906.     // ----------------------------------------------------------------------
  907.  
  908.     //
  909.     //    Set up a "Display" menu that will also allow the user to control
  910.     //    the visibility of the UI Components.
  911.     //
  912.     $displayMenu = `menu -tearOff false -label "Display"`;
  913.  
  914.     $statusLineMenuItem = `menuItem -checkBox true -label "Status Line" 
  915.         UIComponentExampleWindowStatusLineMenuItem`;
  916.  
  917.     $shelfMenuItem = `menuItem -checkBox true -label "Shelf"
  918.         UIComponentExampleWindowShelfMenuItem`;
  919.  
  920.     $layerBarMenuItem = `menuItem -checkBox true -label "Layer Bar"
  921.         UIComponentExampleWindowLayerBarMenuItem`;
  922.  
  923.     $timeLineMenuItem = `menuItem -checkBox true -label "Time Line"
  924.         UIComponentExampleWindowTimeLineMenuItem`;
  925.  
  926.     $playbackRangeMenuItem = `menuItem -checkBox true -label "Playback Range"
  927.         UIComponentExampleWindowPlaybackRangeMenuItem`;
  928.  
  929.     $commandLineMenuItem = `menuItem -checkBox true -label "Command Line"
  930.         UIComponentExampleWindowCommandLineMenuItem`;
  931.  
  932.     $helpLineMenuItem = `menuItem -checkBox true -label "Help Line"
  933.         UIComponentExampleWindowHelpLineMenuItem`;
  934.  
  935.     menuItem -divider true;
  936.  
  937.     $toolboxMenuItem = `menuItem -checkBox true -label "Toolbox"
  938.         UIComponentExampleWindowToolboxMenuItem`;
  939.  
  940.     menuItem -divider true;
  941.  
  942.     $channelBoxMenuItem = `menuItem -checkBox true -label "Channel Box"
  943.         UIComponentExampleWindowChannelBoxMenuItem`;
  944.  
  945.     $attributeEditorMenuItem = `menuItem -checkBox true -label "Attribute Editor"
  946.         UIComponentExampleWindowAttributeEditorMenuItem`;
  947.  
  948.     $optionBoxMenuItem = `menuItem -checkBox true -label "Option Box"
  949.         UIComponentExampleWindowOptionBoxMenuItem`;
  950.  
  951.     // ----------------------------------------------------------------------
  952.  
  953.     //    Set up the top level layouts for your window. Form layouts are not
  954.     //    only the best way to do this but also explicitly required by the
  955.     //    interface to UI Components.
  956.     //
  957.     //    First, create the top level form layout.
  958.     //
  959.     //    Next, create one formLayout for each component you need.
  960.     //
  961.     $mainForm = `formLayout`;
  962.  
  963.     //    Horizontal components.
  964.     //
  965.     $statusLine = `formLayout -parent $mainForm`;
  966.  
  967.     $shelf = `formLayout -parent $mainForm`;
  968.  
  969.     $layerBar = `formLayout -parent $mainForm`;
  970.  
  971.     $timeLine = `formLayout -parent $mainForm`;
  972.  
  973.     $playbackRange = `formLayout -parent $mainForm`;
  974.  
  975.     $commandLine = `formLayout -parent $mainForm`;
  976.  
  977.     $helpLine = `formLayout -parent $mainForm`;
  978.  
  979.     //    This form will be the parent for all the vertical components.
  980.     //
  981.     $middleForm = `formLayout -parent $mainForm`;
  982.  
  983.     //    Vertical components.
  984.     //
  985.     $toolbox = `formLayout -parent $middleForm`;
  986.  
  987.     $channelBox = `formLayout -parent $middleForm`;
  988.  
  989.     $attributeEditor = `formLayout -parent $middleForm`;
  990.  
  991.     $optionBox = `formLayout -parent $middleForm`;
  992.  
  993.     //    The work area represents the non component area of your 
  994.     //    window, ie. where you put your models views, panels or 
  995.     //    whatever.
  996.     //
  997.     $workArea = `formLayout -parent $middleForm`;
  998.  
  999.     // ----------------------------------------------------------------------
  1000.  
  1001.     //    Create the component bars. Supply a unique name for the component
  1002.     //    bar, the formLayout you created for the bar, plus the position
  1003.     //    of the bar that is one of: "top", "left", "bottom", or "right".
  1004.     //
  1005.     createUIComponentBar("Example Top Component Bar",    "top");
  1006.     createUIComponentBar("Example Bottom Component Bar", "bottom");
  1007.     createUIComponentBar("Example Left Component Bar",   "left");
  1008.     createUIComponentBar("Example Right Component Bar",  "right");
  1009.  
  1010.     // ----------------------------------------------------------------------
  1011.  
  1012.     //    Create the components.
  1013.     //
  1014.     $statusLineForm = createUIComponent(
  1015.         "Example Top Component Bar", "Example Status Line", $statusLine);
  1016.  
  1017.     $shelfForm = createUIComponent(
  1018.         "Example Top Component Bar", "Example Shelf", $shelf);
  1019.  
  1020.     $layerBarForm = createUIComponent(
  1021.         "Example Top Component Bar", "Example Layer Bar", $layerBar);
  1022.  
  1023.     $timeLineForm = createUIComponent(
  1024.         "Example Bottom Component Bar", "Example Time Line", $timeLine);
  1025.  
  1026.     $playbackRangeForm = createUIComponent(
  1027.         "Example Bottom Component Bar", "Example Playback Range", $playbackRange);
  1028.  
  1029.     $commandLineForm = createUIComponent(
  1030.         "Example Bottom Component Bar", "Example Command Line", $commandLine);
  1031.  
  1032.     $helpLineForm = createUIComponent(
  1033.         "Example Bottom Component Bar", "Example Help Line", $helpLine);
  1034.  
  1035.     $toolboxForm = createUIComponent(
  1036.         "Example Left Component Bar", "Example Toolbox", $toolbox);
  1037.  
  1038.     $channelBoxForm = createUIComponent(
  1039.         "Example Right Component Bar", "Example Channel Box", $channelBox);
  1040.  
  1041.     $attributeEditorForm = createUIComponent(
  1042.         "Example Right Component Bar", "Example Attribute Editor", $attributeEditor);
  1043.  
  1044.     $optionBoxForm = createUIComponent(
  1045.         "Example Right Component Bar", "Example Option Box", $optionBox);
  1046.  
  1047.     // ----------------------------------------------------------------------
  1048.  
  1049.     //    Indicate to the Component UI code the "work areas" for your window.
  1050.     //    A work area is the non-component form layout for a given orientation.
  1051.     //    In this example the horizontal work area is the middleForm, which 
  1052.     //    contains *all* the vertical components. The vertical work area is 
  1053.     //    simply the workArea form.
  1054.     //
  1055.     //    The component UI needs to know about this formLayout to properly
  1056.     //    handle form attachments when hiding or showing components.
  1057.     //
  1058.     setUIComponentWorkArea("Example Top Component Bar", $middleForm);
  1059.  
  1060.     setUIComponentWorkArea("Example Bottom Component Bar", $middleForm);
  1061.  
  1062.     setUIComponentWorkArea("Example Left Component Bar", $workArea);
  1063.  
  1064.     setUIComponentWorkArea("Example Right Component Bar", $workArea);
  1065.  
  1066.     // ----------------------------------------------------------------------
  1067.  
  1068.     //    Set up callbacks so your window will be notified when the
  1069.     //    visibility state of components changes.
  1070.     //
  1071.     //    You may not require these callbacks. In fact, in most cases
  1072.     //    you probably don't need to know when your components change
  1073.     //    visibility state. The callbacks are included them here for 
  1074.     //    demonstration purposes. In fact, the procedures attached to 
  1075.     //    these callbacks actually create the Component UI when the 
  1076.     //    component is made visible for the first time.
  1077.     //
  1078.     //    As an alternative you could create all your components when
  1079.     //    the window is created with direct calls to the following
  1080.     //    local procedures:
  1081.     //
  1082.     //    proc createStatusLine(string $parent)
  1083.     //    proc createShelf(string $parent)
  1084.     //    proc createLayerBar(string $parent)
  1085.     //    proc createWorkArea(string $parent)
  1086.     //    proc createTimeLine(string $parent)
  1087.     //    proc createPlaybackRange(string $parent)
  1088.     //    proc createCommandLine(string $parent)
  1089.     //    proc createHelpLine(string $parent)
  1090.     //    proc createToolbox(string $parent)
  1091.     //    proc createChannelBox(string $parent)
  1092.     //    proc createAttributeEditor(string $parent)
  1093.     //    proc createOptionBox(string $parent)
  1094.     //
  1095.     setUIComponentStateCallback("Example Status Line", 
  1096.         "UIComponentExampleWindowStatusLineStateChange");
  1097.  
  1098.     setUIComponentStateCallback("Example Shelf", 
  1099.         "UIComponentExampleWindowShelfStateChange");
  1100.  
  1101.     setUIComponentStateCallback("Example Layer Bar", 
  1102.         "UIComponentExampleWindowLayerBarStateChange");
  1103.  
  1104.     setUIComponentStateCallback("Example Time Line", 
  1105.         "UIComponentExampleWindowTimeLineStateChange");
  1106.  
  1107.     setUIComponentStateCallback("Example Playback Range", 
  1108.         "UIComponentExampleWindowPlaybackRangeStateChange");
  1109.  
  1110.     setUIComponentStateCallback("Example Command Line", 
  1111.         "UIComponentExampleWindowCommandLineStateChange");
  1112.  
  1113.     setUIComponentStateCallback("Example Help Line", 
  1114.         "UIComponentExampleWindowHelpLineStateChange");
  1115.  
  1116.     setUIComponentStateCallback("Example Toolbox", 
  1117.         "UIComponentExampleWindowToolboxStateChange");
  1118.  
  1119.     setUIComponentStateCallback("Example Channel Box", 
  1120.         "UIComponentExampleWindowChannelBoxStateChange");
  1121.  
  1122.     setUIComponentStateCallback("Example Attribute Editor", 
  1123.         "UIComponentExampleWindowAttributeEditorStateChange");
  1124.  
  1125.     setUIComponentStateCallback("Example Option Box", 
  1126.         "UIComponentExampleWindowOptionBoxStateChange");
  1127.  
  1128.     // ----------------------------------------------------------------------
  1129.  
  1130.     //    Create the main content for your window.
  1131.     //
  1132.     createWorkArea($workArea);
  1133.  
  1134.     // ----------------------------------------------------------------------
  1135.  
  1136.     //    Attach commands to the menu items that will toggle the visibility
  1137.     //    state of the UI Components.
  1138.     //
  1139.     menu -edit 
  1140.         -postMenuCommand ("UIComponentExampleWindowUpdateDisplayMenu")
  1141.         $displayMenu;
  1142.  
  1143.     menuItem -edit 
  1144.         -command ("toggleUIComponentVisibility \"Example Status Line\"")
  1145.         $statusLineMenuItem;
  1146.  
  1147.     menuItem -edit 
  1148.         -command ("toggleUIComponentVisibility \"Example Shelf\"")
  1149.         $shelfMenuItem;
  1150.  
  1151.     menuItem -edit 
  1152.         -command ("toggleUIComponentVisibility \"Example Layer Bar\"")
  1153.         $layerBarMenuItem;
  1154.  
  1155.     menuItem -edit 
  1156.         -command ("toggleUIComponentVisibility \"Example Time Line\"")
  1157.         $timeLineMenuItem;
  1158.  
  1159.     menuItem -edit 
  1160.         -command ("toggleUIComponentVisibility \"Example Playback Range\"")
  1161.         $playbackRangeMenuItem;
  1162.  
  1163.     menuItem -edit 
  1164.         -command ("toggleUIComponentVisibility \"Example Command Line\"")
  1165.         $commandLineMenuItem;
  1166.  
  1167.     menuItem -edit 
  1168.         -command ("toggleUIComponentVisibility \"Example Help Line\"")
  1169.         $helpLineMenuItem;
  1170.  
  1171.     menuItem -edit
  1172.         -command ("toggleUIComponentVisibility \"Example Toolbox\"")
  1173.         $toolboxMenuItem;
  1174.  
  1175.     menuItem -edit
  1176.         -command ("toggleUIComponentVisibility \"Example Channel Box\"")
  1177.         $channelBoxMenuItem;
  1178.  
  1179.     menuItem -edit
  1180.         -command ("toggleUIComponentVisibility \"Example Attribute Editor\"")
  1181.         $attributeEditorMenuItem;
  1182.  
  1183.     menuItem -edit
  1184.         -command ("toggleUIComponentVisibility \"Example Option Box\"")
  1185.         $optionBoxMenuItem;
  1186.  
  1187.     //    Now make all the form attachments.
  1188.     //
  1189.     formLayout -edit
  1190.         -attachForm     $toolbox             "top"    0
  1191.         -attachForm     $toolbox             "left"   0
  1192.         -attachForm     $toolbox             "bottom" 0
  1193.         -attachNone     $toolbox             "right"
  1194.  
  1195.         -attachForm     $workArea            "top"    0
  1196.         -attachControl  $workArea            "left"   0 $toolbox
  1197.         -attachForm     $workArea            "bottom" 0
  1198.         -attachControl  $workArea            "right"  0 $channelBox
  1199.  
  1200.         -attachForm     $channelBox          "top"    0
  1201.         -attachNone     $channelBox          "left"
  1202.         -attachForm     $channelBox          "bottom" 0
  1203.         -attachControl  $channelBox          "right"  0 $attributeEditor
  1204.  
  1205.         -attachForm     $attributeEditor     "top"    0
  1206.         -attachNone     $attributeEditor     "left"
  1207.         -attachForm     $attributeEditor     "bottom" 0
  1208.         -attachControl  $attributeEditor     "right"  0 $optionBox
  1209.  
  1210.         -attachForm     $optionBox           "top"    0
  1211.         -attachNone     $optionBox           "left"
  1212.         -attachForm     $optionBox           "bottom" 0
  1213.         -attachForm     $optionBox           "right"  0
  1214.         $middleForm;
  1215.  
  1216.     formLayout -edit
  1217.         -attachForm     $statusLine          "top"    0
  1218.         -attachForm     $statusLine          "left"   0
  1219.         -attachNone     $statusLine          "bottom"
  1220.         -attachForm     $statusLine          "right"  0
  1221.  
  1222.         -attachControl  $shelf               "top"    0 $statusLine
  1223.         -attachForm     $shelf               "left"   0
  1224.         -attachNone     $shelf               "bottom"
  1225.         -attachForm     $shelf               "right"  0
  1226.  
  1227.         -attachControl  $layerBar            "top"    0 $shelf
  1228.         -attachForm     $layerBar            "left"   0
  1229.         -attachNone     $layerBar            "bottom"
  1230.         -attachForm     $layerBar            "right"  0
  1231.  
  1232.         -attachControl  $middleForm          "top"    0 $layerBar
  1233.         -attachForm     $middleForm          "left"   0
  1234.         -attachControl  $middleForm          "bottom" 0 $timeLine
  1235.         -attachForm     $middleForm          "right"  0
  1236.  
  1237.         -attachNone     $timeLine            "top"
  1238.         -attachForm     $timeLine            "left"   0
  1239.         -attachForm     $timeLine            "right"  0
  1240.         -attachControl  $timeLine            "bottom" 0 $playbackRange
  1241.  
  1242.         -attachNone     $playbackRange       "top"
  1243.         -attachForm     $playbackRange       "left"   0
  1244.         -attachForm     $playbackRange       "right"  0
  1245.         -attachControl  $playbackRange       "bottom" 0 $commandLine
  1246.  
  1247.         -attachNone     $commandLine         "top"
  1248.         -attachForm     $commandLine         "left"   0
  1249.         -attachForm     $commandLine         "right"  0
  1250.         -attachControl  $commandLine         "bottom" 0 $helpLine
  1251.  
  1252.         -attachNone     $helpLine            "top"
  1253.         -attachForm     $helpLine            "left"   0
  1254.         -attachForm     $helpLine            "bottom" 0
  1255.         -attachForm     $helpLine            "right"  0
  1256.         $mainForm;
  1257.  
  1258.     //    Set up an initial visibility state for all the components.
  1259.     //
  1260.     int $initialStatusLineState    = true;
  1261.     int $initialShelfState         = true;
  1262.     int $initialLayerBarState      = false;
  1263.     int $initialTimeLineState      = false;
  1264.     int $initialPlaybackRangeState = false;
  1265.     int $initialCommandLineState   = true;
  1266.     int $initialHelpLineState      = false;
  1267.     int $initialToolboxState       = true;
  1268.     int $initialChannelsState      = true;
  1269.     int $initialAttributesState    = false;
  1270.     int $initialOptionsState       = false;
  1271.  
  1272.     if ($initialStatusLineState) {
  1273.         toggleUIComponentVisibility "Example Status Line";
  1274.     }
  1275.     if ($initialShelfState) {
  1276.         toggleUIComponentVisibility "Example Shelf";
  1277.     }
  1278.     if ($initialLayerBarState) {
  1279.         toggleUIComponentVisibility "Example Layer Bar";
  1280.     }
  1281.     if ($initialTimeLineState) {
  1282.         toggleUIComponentVisibility "Example Time Line";
  1283.     }
  1284.     if ($initialPlaybackRangeState) {
  1285.         toggleUIComponentVisibility "Example Playback Range";
  1286.     }
  1287.     if ($initialCommandLineState) {
  1288.         toggleUIComponentVisibility "Example Command Line";
  1289.     }
  1290.     if ($initialHelpLineState) {
  1291.         toggleUIComponentVisibility "Example Help Line";
  1292.     }
  1293.     if ($initialToolboxState) {
  1294.         toggleUIComponentVisibility "Example Toolbox";
  1295.     }
  1296.     if ($initialChannelsState) {
  1297.         toggleUIComponentVisibility "Example Channel Box";
  1298.     }
  1299.     if ($initialAttributesState) {
  1300.         toggleUIComponentVisibility "Example Attribute Editor";
  1301.     }
  1302.     if ($initialOptionsState) {
  1303.         toggleUIComponentVisibility "Example Option Box";
  1304.     }
  1305.  
  1306.     showWindow $window;
  1307. }
  1308.